home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / fortran.zip / SBM.MAC < prev    next >
Text File  |  1991-01-09  |  8KB  |  337 lines

  1.  list-
  2. CR        equ  0dh
  3. LF        equ  0ah
  4. ESC       equ  1Bh
  5. FF        equ  0Ch
  6. TAB       equ  09h
  7. BS        equ  08h
  8. COMMA     equ  2Ch
  9. QUOTE     equ  27h
  10. QUOTES    equ  '"'
  11. TILDE     equ  '~'
  12. MARKER    equ  '|'
  13. False     equ  0
  14. True      equ  1
  15.  
  16. ;                             M A C R O S
  17. ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  18. ;------------------------------------------------------------
  19. ^HANDLE macro {IOCB}
  20.     mov  bx,offset {iocb}
  21.     mov  bp,[bx-2]
  22.  endm
  23. ;-----------------------------------
  24. ^OPEN_INPUT macro {filename}
  25.     mov  bx,offset {filename}
  26.     call v06
  27.  endm
  28. ;-----------------------------------
  29. ^OPEN_OUTPUT macro {filename}
  30.     mov  bx,offset {filename}
  31.     call v30
  32.  endm
  33. ;-----------------------------------
  34. ^READ macro {iocb},{alternate}
  35.     mov  bx,offset {iocb}
  36.  ifn type({alternate})=type()
  37.     mov  di,offset {alternate}
  38.     call v05  ; buffin_alt
  39.  else
  40.     call v04  ; buffin
  41.  endif
  42.  endm
  43. ;--------------------------------
  44. ^WRITE macro {iocb}, {buffer}, {tail}
  45.  if value({iocb})=1
  46.     mov  bp,1
  47.  elseif value({iocb})='*'
  48.     mov  bp,1
  49.  else
  50.     mov  bx,offset {iocb}
  51.     mov  bp,[bx-2]
  52.  endif
  53.  ifn type({buffer})=type()
  54.     mov  bx,offset {buffer}
  55.  endif
  56.     call v33
  57.  if value({tail})=cr
  58.    ^crlf {iocb}
  59.  endif
  60.  Endm
  61. ;--------------------------------
  62. ;$P
  63.  
  64. ^OUTBLK macro {iocb},{string},{tail}
  65.  if value({iocb})=1
  66.     mov  bp,1
  67.  else
  68.     mov  bx,offset {iocb}
  69.     mov  bp,[bx-2]
  70.  endif
  71.     call v31
  72.     db {string}
  73.  if value({tail})=cr
  74.     db cr,lf,0
  75.  else
  76.     db {tail}
  77.  endif
  78.  Endm
  79. ;--------------------------------
  80. ^SHOW_CHAR macro {char}
  81.     mov  ah,2
  82.  ifn type({char})=type()
  83.     mov  dl,{char}
  84.  else
  85.     mov  dl,al
  86.  endif
  87.     int  21h
  88.  Endm
  89. ;--------------------------------
  90. ^CRLF macro {IOCB}
  91.  if value({iocb})=1
  92.     mov  bp,1
  93.  else
  94.     mov  bp,offset {iocb}
  95.     mov  bp,[bp-2]
  96.  endif
  97.     call v31  ; outblk
  98.     db   cr,lf,0
  99.  Endm
  100. ;-----------------------------------
  101. ^CONOUT macro {string},{tail}
  102.     call v07
  103.     db {string}
  104.  if value({tail})=cr
  105.     db cr,lf,0
  106.  else
  107.     db {tail}
  108.  endif
  109.  Endm
  110. ;------------------------------------
  111. ^REWIND macro {filename}
  112.     mov  bx,offset {filename}
  113.     mov  bx,[bx-2]
  114.     mov  ax,4200h
  115.     mov  cx,00
  116.     mov  dx,00
  117.     int  21h
  118.  Endm
  119. ;----------------------------------------
  120. ;$P
  121.  
  122. ^GET_FILE_POINTER macro {filename}, {locn}
  123.     mov  bx,offset {filename}
  124.     mov  bx,[bx-2]
  125.  if value({locn}) = 'S'
  126.     mov  ax,4200h
  127.  endif
  128.  if value({locn}) = 'C'
  129.     mov  ax,4201h
  130.  endif
  131.  if value({locn}) = 'E'
  132.     mov  ax,4202h
  133.  endif
  134.     mov  cx,00
  135.     mov  dx,00
  136.     int  21h
  137.     mov  cx,ax
  138.  Endm
  139. ;----------------------------------------
  140. ^LOAD_FILE macro {filename}, {address}
  141.     mov  bx,offset {filename}
  142.     mov  bx,[bx-2]
  143.     mov  dx,offset {address}
  144.     mov  ah,3Fh
  145.     int  21h
  146.  Endm
  147. ;----------------------------------------
  148. ^WRITE_FILE macro {filename}, {address}
  149.     mov  bx,offset {filename}
  150.     mov  bx,[bx-2]
  151.     mov  dx,offset {address}
  152.     mov  ah,40h
  153.     int  21h
  154.  Endm
  155. ;----------------------------------------
  156. ^COMMAND_TAIL_TO macro {array}
  157.     mov  di,offset {array}
  158.     call v10
  159.  Endm
  160. ;--------------------------
  161. ^FIND_CHAR macro {char},{array}
  162.  if type({array}) = type(bx)
  163.     mov  bx, {array}
  164.  else
  165.     mov  bx, offset {array}
  166.  endif
  167.     mov  ah,{char}
  168.     call v19
  169.  Endm
  170. ;------------------------
  171. ;$P
  172.  
  173. ^FNB_THEN_COPY macro {source},{destination}
  174.     mov  bx,offset {source}
  175.     mov  di,offset {destination}
  176.     call v21
  177.  Endm
  178.  ;----------------------------
  179. ^DATA macro {array}, {string}
  180.  if type({array}) = type(bx)
  181.     mov  di,{array}
  182.  else
  183.     mov  di,offset {array}
  184.  endif
  185.     call v42
  186.     db {string},0
  187.  Endm
  188. ; ----------------------------
  189. ^SETDATA macro {destin}, {source}
  190.     mov  si,offset {source}
  191.     mov  di,offset {destin}
  192.     mov  cx,[si-2]
  193.     rep
  194.     movsb
  195.  Endm
  196. ; ----------------------------
  197. ^COPY macro {from},{to}
  198.  if type({from}) = type(bx)
  199.     mov  bx,{from}
  200.  else
  201.     mov  bx,offset {from}
  202.  endif
  203.  if type({to}) = type(bx)
  204.     mov  di,{to}
  205.  else
  206.     mov  di,offset {to}
  207.  endif
  208.     call v08  ; copy
  209.  Endm
  210. ; ----------------------------
  211. ^COPY_TIL macro {char}, {from}, {to}
  212.  if type({from}) = type(bx)
  213.     mov  bx,{from}
  214.  else
  215.     mov  bx,offset {from}
  216.  endif
  217.  if type({to}) = type(bx)
  218.     mov  di,{to}
  219.  else
  220.     mov  di,offset {to}
  221.  endif
  222.     mov  ah,{char}
  223.     call v11
  224.  Endm
  225. ; -----------------------------------------
  226. ^FILL macro {buffer},{spaces},{char}
  227.     mov  di,offset {buffer}
  228.     mov  al,{char}
  229.     mov  cx,{spaces}
  230.     rep
  231.     stosb
  232.  Endm
  233. ; -----------------------------------------
  234. ; create a new file, deleting any existing.
  235. ^DOS_CREATE macro {filename}
  236.     jmp  b
  237. a   db  {filename},0
  238. b   mov  dx,offset a
  239.     mov  cx,00
  240.     mov  ah,3Ch
  241.     int  21h
  242.  Endm
  243. ; ---------------------------------------------------------------
  244. ;$P
  245.  
  246. ; COMPARE: macro to compare an unknown string (given) with a known (model)
  247. ;          string.  The model must be an ASCIIZ string and may be defined as
  248. ;          an array name or immediate data.
  249. ;          compare known,'model'          compare known, other-known
  250. ^compare macro {given}, {model}
  251.     mov  si,offset {given}
  252.   if type({model}) and type ([0])=0
  253.     call v17
  254.     db {model},0
  255.  Else
  256.     mov  bx,offset {model}
  257.     call v41
  258.  Endif
  259.  Endm
  260.  
  261. ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  262. ; PARSE: macro to parse the leading keword from a given string.  The keword
  263. ;        is removed from the string and the string then left-justified.
  264. ;        delims optional if you want more than blank, comma, equals.
  265. ^PARSE macro {String_address}, {Keword_address}, {delims}
  266.     call v36
  267.     Dw offset {String_address}, offset {keword_address}
  268.     Db {delims},0
  269.  Endm
  270. ;-- the following version loads the registers before the call and is needed
  271. ;-- for RTL operations.
  272. ^PARCE macro {String_address}, {Keword_address}, {delims}
  273.     mov  si,offset {string_address}
  274.     mov  dx,si
  275.     mov  di,offset {keword_address}
  276.     mov  bp,offset {delims}
  277.     call v34
  278.  Endm
  279. ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  280. ^PARSE_ONLY macro {String_address}, {Keword_address}, char
  281.     mov  ah,char
  282.     mov  si,offset {string_address}
  283.     mov  dx,si
  284.     mov  di,offset {keword_address}
  285.     call v35
  286.  Endm
  287. ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  288. ^TABLE_LOOKUP macro {model},{table}
  289.     mov  bp,offset {model}
  290.     mov  si,offset {table}
  291.     call v44
  292.  endm
  293. ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  294. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  295. ^TABLE_ADD macro {token}
  296.     mov  di,si
  297.     mov  si,offset {token}
  298.     call v09
  299.     mov  byte[di],'$'
  300.  endm
  301. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  302. ^UPCASE macro {string}
  303.     mov  di,offset {string}
  304.     mov  si,offset {string}
  305.     call v09
  306.  endm
  307. ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  308. ^CTOI macro {variable}   ; converts variable to binry. CY if not numeric.
  309.     mov  al,{variable}
  310.     call v12
  311.  endm
  312. ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  313. ^DECBIN macro {string}        ; converts string to binry, DX,AX
  314.     mov  bx,offset {string}
  315.     call v14
  316.  Endm
  317. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  318. ^BINDEC macro {string},{nchar}  ; converts DX,AX to string
  319.     mov  di,offset {string}
  320.     mov  cx,{nchar}
  321.     call v03
  322.  Endm
  323. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  324. ^APPEND macro {string1}, {string2}
  325.    ^find_char 0,{string1}
  326.     mov  di,bx
  327.     mov  bx,offset {string2}
  328.     call v08
  329.  Endm
  330. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  331. ^ASCNTR macro {array}
  332.     mov  bx,offset {array}
  333.     call v01
  334.  Endm
  335. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  336. ; END MACROS
  337.